package cn.johnyu;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

@RestController
@EnableAsync
public class CommonController {
   @Autowired
   private UserManager userManager;
    @RequestMapping("/login")
    public User login(String name){
        User user=new User();
        user.setId(100);user.setName("john");

        String s=null;
        Future<String> f=userManager.work();
        String info= null;
        try {
            info = f.get();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }


        System.out.println(info);
        return user;

    }
}
